import React, { Component } from 'react'
import { Redirect, Route, Switch } from "react-router-dom";
// import { getUrlParams} from "../../utils/urlParams";

import clientView from "./view/view";
import ClientActivityList from "./list/activityList";
import ClientFriendList from "./list/friendList";
import clientEdit from "./edit/edit";
import ClientMessageList from "./list/messageList";

import '../../../static/css/client.less'
import { Menu, Avatar } from "antd";
import { UserOutlined } from '@ant-design/icons';
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
import ClientArticleList from "./list/articleList";

const { SubMenu } = Menu
class ClientMain extends Component {
    constructor(props) {
        super(props);
        this.state = {
            // subContentName:'view'
        }
    }
    componentDidMount() {
        document.title = '个人首页'
    }
    handleClick = e => {
        console.log('click ', e);
        console.log(e.key)
        var url1, win
        switch (e.key) {
            case 'articleManage': {
                this.props.history.push('/client/article/list')
                break
            }
            case 'articleCreate': {
                //
                url1 = '/article/edit'
                win = window.open(url1, '_blank')
                win.focus()

                break
            }
            case 'messageManage': {
                //
                this.props.history.push('/client/message/list')
                break
            }
            case 'friendManage': {
                //
                this.props.history.push('/client/friend/list')
                break
            }
            case 'activityManage': {
                this.props.history.push('/client/activity/list')
                break
            }
            case 'activityCreate': {
                // 暂时不处理
                url1 = '/activity/edit'
                win = window.open(url1, '_blank')
                win.focus()
                break
            }
            case 'clientEdit': {
                this.props.history.push('/client/edit')
                break
            }
            default: {
                break
            }
        }
    };
    // componentDidMount() {
    //     const type = getUrlParams('')
    // }

    render() {
        return (
            <>
                <div className='clientInfo'>
                    <Avatar className='image' shape='square' size={90} icon={<UserOutlined />} />
                    <p className='name'>name</p>
                    <p className='info'>info</p>
                </div>
                <div className='clientMain'>

                    <div className='menu'>
                        <Menu
                            onClick={this.handleClick}
                            style={{ width: 256 }}
                            mode="inline"
                        >
                            <SubMenu key="article" icon={<MailOutlined />} title="文章管理">
                                <Menu.Item key="articleManage">文章管理</Menu.Item>
                                <Menu.Item key="articleCreate">文章创作</Menu.Item>

                            </SubMenu>
                            <SubMenu key="communication" icon={<AppstoreOutlined />} title="好友中心">
                                <Menu.Item key="messageManage">消息管理</Menu.Item>
                                <Menu.Item key="friendManage">好友管理</Menu.Item>
                            </SubMenu>
                            <SubMenu key="activity" icon={<SettingOutlined />} title="活动中心">
                                <Menu.Item key="activityManage">活动管理</Menu.Item>
                                <Menu.Item key="activityCreate">活动创建</Menu.Item>
                            </SubMenu>
                            <Menu.Item key="clientEdit">用户修改</Menu.Item>
                        </Menu>
                    </div>
                    <div className='clientContent'>
                        <Switch>
                            <Route path='/client/view' component={clientView} name='clientView' />
                            <Route path='/client/edit' component={clientEdit} name='clientEdit' />
                            <Route path='/client/activity/list' component={ClientActivityList} name='ClientActivityList' />
                            <Route path='/client/article/list' component={ClientArticleList} name='ClientArticleList' />
                            <Route path='/client/friend/list' component={ClientFriendList} name='ClientFriendList' />
                            <Route path='/client/message/list' component={ClientMessageList} name='ClientMessageList' />
                            <Redirect from="*" to="/NotFound" />
                        </Switch>
                    </div>
                </div>
            </>

        )
    }
}

export default ClientMain
